package com.laiketui.app.controller.auction;

import com.laiketui.app.api.auction.AuctionService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;

/**
 * 竞拍
 *
 * @author Trick
 * @date 2021/4/22 9:59
 */
@Api(tags = "插件-竞拍")
@RestController
//@RequestMapping("/plugin/auction")
public class AuctionController {

//    @Autowired
    private AuctionService auctionService;

    /*@ApiOperation("砍价商品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "砍价状态类型 ready,running,my", required = true, dataType = "string", paramType = "form")
    })
    @PostMapping("/index")
    @HttpApiMethod(urlMapping = "app.auction.index")
    public Result index(MainVo vo, String type) {
        try {
            return Result.success(auctionService.index(vo, type));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }


    @ApiOperation("获取竞拍商品明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "竞拍商品活动id", required = true, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "isfx", value = "是否是分享", required = true, dataType = "int", paramType = "form")
    })
    @PostMapping("/auctionDetail")
    @HttpApiMethod(urlMapping = {"app.auction.detail","app.auction.end_detail"})
    public Result auctionDetail(MainVo vo, int id, String isfx) {
        try {
            return Result.success(auctionService.auctionGoodsDetail(vo, id, isfx));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation("获取竞拍商品明细-热数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "竞拍商品活动id", required = true, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "isfx", value = "是否是分享", required = true, dataType = "int", paramType = "form")
    })
    @PostMapping("/timeRequest")
    @HttpApiMethod(urlMapping = "app.auction.timeRequest")
    public Result timeRequest(MainVo vo, int id) {
        try {
            return Result.success(auctionService.timeRequest(vo, id));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation("交押金")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "竞拍商品活动id", required = true, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "password", value = "支付密码", required = true, dataType = "string", paramType = "form"),
            @ApiImplicitParam(name = "type", value = "支付类型 wallet_pay...", required = true, dataType = "string", paramType = "form"),
            @ApiImplicitParam(name = "address_id", value = "用户地址", dataType = "int", paramType = "form")
    })
    @PostMapping("/goPay")
    @HttpApiMethod(urlMapping = "app.auction.go_pay")
    public Result goPay(MainVo vo, int id, String password, @ParamsMapping("type") String payType, @ParamsMapping("address_id") Integer addressId) {
        try {
            return Result.success(auctionService.goPay(vo, id, password, payType, addressId));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }

    @ApiOperation("出价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "竞拍商品活动id", required = true, dataType = "int", paramType = "form"),
            @ApiImplicitParam(name = "price", value = "金额", required = true, dataType = "string", paramType = "form")
    })
    @PostMapping("/bid")
    @HttpApiMethod(urlMapping = "app.auction.bid")
    public Result bid(MainVo vo, int id, BigDecimal price) {
        try {
            return Result.success(auctionService.bid(vo, id, price));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }


    @ApiOperation("竞拍规则")
    @PostMapping("/rule")
    @HttpApiMethod(urlMapping = "app.auction.rule")
    public Result rule(MainVo vo) {
        try {
            return Result.success(auctionService.rule(vo));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }


    @ApiOperation("出价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "竞拍商品活动id", required = true, dataType = "int", paramType = "form")
    })
    @PostMapping("/record")
    @HttpApiMethod(urlMapping = "app.auction.record")
    public Result record(MainVo vo, int id) {
        try {
            return Result.success(auctionService.record(vo, id));
        } catch (LaiKeAPIException e) {
            return Result.error(e.getCode(), e.getMessage());
        }
    }*/
}
